package cn.javase.base.reflect;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

public class _10_利用反射使用成员方法 {
    public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
        Student student = new Student();
        Class<Student> studentClass = Student.class;
        Method sayHello = studentClass.getDeclaredMethod("sayHello", String.class);
        sayHello.setAccessible(true);
        Object res = sayHello.invoke(student, "人生入戏");
        System.out.println(res);
    }
}
